﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<script src="~/lib/layui/layui.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"> 工作站</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="请输入" class="layui-input" style="width:200px" id="Productionname" />
            </div>
            <button type="button" class="layui-btn layui-btn-primary" lay-on="test-page-custom">
                <i class="layui-icon layui-icon-search"></i>
            </button>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">任务名称</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="请输入" class="layui-input" style="width:200px" id="ProcessName">
            </div>
        </div>
        </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">排产数量</label>
            <div class="layui-input-inline">
               <input type="number" name="price_min" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number" style="width:200px" id="Productionnum">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
                <input type="date" class="layui-input" id="StartTime1" placeholder="yyyy-MM-dd">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">生产时长</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="请输入" class="layui-input" style="width:200px" id="ProductionTime">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">完成时间</label>
            <div class="layui-input-inline">
                <input type="date" class="layui-input" id="FinshTime" placeholder="yyyy-MM-dd">
            </div>
        </div>
    </div>
  <div class="layui-btn-container" style="float:left">
            <button type="button" class="layui-btn layui-btn-radius" onclick="Stach()">添加</button>
   </div>
    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
    <script>

        
        var TaskName="";
        var QuantityProduceds = location.href.split("=")[1];
        var QuantityProduced = "";
        function Stach() {

            var date = {
                
              Productionname:$('#Productionname').val(),
              Productionnum:$('#Productionnum').val(),
              StartTime:$('#StartTime1').val(),
              ProductionTime:$('#ProductionTime').val(),
              FinshTime:$('#FinshTime').val(),
              TaskNumber:"MG" + Math.random().toString().substring(2, 6),
              TaskName:"78",
              QuantityProduced:QuantityProduced,
              ProductionTypeid: QuantityProduceds,
                processname: $('#ProcessName').val()

            };
            console.log(date);
          
            $.ajax({
                url: '@ViewBag.FoundationWrite' +"/api/Jocker/ProductionCreate",
                type: 'post',
                data: JSON.stringify(date),
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    if (res.code > 0) {
                        alert("添加成功");
                        // location.href = "../Document/index";

                    }
                    else {

                    }

                }

            })



        }
        layui.use(function () {
            var $ = layui.$;
            var layer = layui.layer;
            var util = layui.util;
            var form = layui.form;
            var table = layui.table
            // 事件

            util.on('lay-on', {
                'test-page-custom': function () {
                    layer.open({
                        type: 1,
                        area: '900px',
                        resize: false,
                        shadeClose: true,
                        title: 'demo : 工作站选择',
                        content: `
                                <div class="layui-form-item">
                                <div class="layui-input-group">
                                    <div class="layui-input-prefix">
                                        供应商编码
                                    </div>
                                    <div>
                                     <input id="GEtnumber" type="text" placeholder="请输入供应商编码" class="layui-input">
                                    </div>

                                    <div class="layui-input-prefix" style="left:50px">
                                     胶化
                                    </div>
                                    <div style="left:50px">
                                            <div class="layui-col-md6">
                                                    <select id="processid">
                                              <option value="">请选择</option>
                                              <option value="AAA">选项 A</option>
                                              <option value="BBB">选项 B</option>
                                              <option value="CCC">选项 C</option>
                                            </select>
                                          </div>
                                    </div>

                                    <div class="layui-input-prefix" style="left:100px">
                                      所属空间
                                    </div>
                                    <div style="left:100px">
                                             <div class="layui-col-md6">
                                                    <select id="workshopid">
                                              <option value="">请选择</option>
                                              <option value="AAA">选项 A</option>
                                              <option value="BBB">选项 B</option>
                                              <option value="CCC">选项 C</option>
                                            </select>
                                          </div>
                                    </div>                       
                                     <div style="left:100px">
                                       <button type="button" class="layui-btn layui-btn-radius" onclick="StashHtml()">查询</button>
                                     </div>
                                </div>
                                <div>

                                        <table class="layui-hide" id="ID-table-demo-data"></table>
                                
                                </div>
                         
                               
                           </div> `,
                        success: function () {
                            // 对弹层中的表单进行初始化渲染
                            form.render();
                            // 表单提交事件
                            form.on('submit(demo-login)', function (data) {
                                var field = data.field; // 获取表单字段值
                                // 显示填写结果，仅作演示用
                                layer.alert(JSON.stringify(field), {
                                    title: '当前填写的字段值'
                                });             
                                // 此处可执行 Ajax 等操作
                                // …
                                return false; // 阻止默认 form 跳转
                            });

                            StashHtml()
                            //仓库显示
                            function StashHtml() {

                                var date={

                                 GEtnumber: $("#GEtnumber").val(),
                                 processid:0,
                                 workshopid:0,
                                }
                            
                                $.ajax({

                                    url: '@ViewBag.FoundationRead'+"/api/Production/WorkStationHtml",
                                    data: JSON.stringify({date}),
                                    type: "post",
                                    async: false,
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: res => {

                                        console.log(res.data)
                                        layui.use('table', function () {
                                            var table = layui.table;

                                            // 已知数据渲染
                                            var inst = table.render({
                                                elem: '#ID-table-demo-data',
                                                cols: [[ //标题栏
                                                    { type: 'checkbox', title: '复选框', fixed: true }, // 单选框
                                                    { field: 'workStations', title: '工作站编号', width: 200, sort: true },
                                                    { field: 'workStationName', title: '工作站名称', width: 200 },
                                                    { field: 'workStationlocation', title: '工作站地点', width: 200 },
                                                    { field: 'workshopName', title: '所在车间名称', width: 200 },
                                                    { field: 'processName', title: '所属工序', width: 200 },
                                                    { field: 'workStationRemarks', title: '备注', width: 200 },
                                                ]],
                                                data: res.data,
                                                //skin: 'line', // 表格风格
                                                //even: true,
                                                page: true, // 是否显示分页
                                                limits: [5, 10, 15],
                                                limit: 5 // 每页默认显示的数量
                                            });
                                        });
                                    }

                                })





                            }
                            var getid = 0;

                            // 触发表格复选框选择
                            table.on('checkbox(ID-table-demo-data)', function (obj) {
                                getid = obj.data.workid
                               goback()
                                console.log(getid);
                            });
                            form.on('submit(demo-logins)', function (data) {
                                
                                  layer.close(layer.index); // 关闭当前最新弹层

                                return false;
                             
                            });
                           
                            function goback()
                            {
                                $.ajax({
                                    url: '@ViewBag.FoundationRead'+ "/api/Production/WorkStationback",
                                    data: JSON.stringify({Workid:getid}),
                                    type: "post",
                                    async: false,
                                    dataType: "json",
                                    contentType: "application/json",
                                    success: res => {
                                        console.log(res.data); 

                                         $("#Productionname").val(res.data[0].workStationName)  
                                         QuantityProduced=res.data[0].workStations
                                    }

                                })


                            }

                          


                        }

                    });
                }
            })
        })


    </script>


    <script>



    </script>
</body>
</html>

